<template>
    <div class="login_container">
        <div class="login_form">
           <h3 class="title">后台管理系统</h3>     
           <el-form ref="formRef" :model="loginForm" label-width="auto"> 
               <el-form-item>
                <el-input v-model="loginForm.username" placeholder="请输入用户名">
                    <template #prefix>
                        <icon-ep-user />
                    </template>
                </el-input>
               </el-form-item>
               <el-form-item>
                <el-input v-model="loginForm.password" placeholder="请输入密码" type="password" >
                    <template #prefix>
                        <icon-ep-lock />
                    </template>
                </el-input>
               </el-form-item>
               <el-form-item id="aaa">
                <div class="remember">
                    <el-checkbox v-model="loginForm.rememberMe" label="记住我"></el-checkbox>
                    <el-text type="primary">忘记密码？</el-text>
                </div>
               </el-form-item>
               <el-divider>
                    其他登陆方式
                </el-divider>
                <div class="otherLogin">
                    <icon-ep-apple />
                    <icon-ep-ChromeFilled />
                    <icon-ep-cherry />
                </div>
               <el-form-item >
                <el-button type="primary" class="loginBtn" @click="handleLogin">登录</el-button>
               </el-form-item>
           </el-form>
        </div>
    </div>
</template>
<script setup>
    import { login } from '@/api/auth'
    const loginForm = ref({
        username: '',
        password: '',
        rememberMe: false
    })
    function handleLogin() {
        login(loginForm.value).then(data => {
            if(data.code == 200){
                //将token存储到pinia中
                console.log('登录成功')
            }
        })
    }
</script>


<style lang="scss" scoped>
.remember{
    width: 100%;
    display: flex;
    justify-content: space-between;
}
.otherLogin{
    width: 100%;
    display: flex;
    justify-content: space-evenly;
}
.login_container{
    background-image: url("@/assets/img/login_bg.png");
    background-size: 100% 100%;
    height: 100vh;
    display: flex;
    justify-content: flex-end;
    .login_form{ 
        display: flex;
        flex-direction: column;//垂直分布
        width: 50%;
        background-color: white;
        justify-content: center;
        align-items: center;
        .title{ 
            margin-bottom: 20px;
        }
        .el-form{
            width: 60%;
            .el-form-item{
                width: 100%;
            }
            .loginBtn{
                margin: 10px auto;
                width: 100%;
            }
        }
    }
}
</style>